package gemini.castor.ui.client.page.content.information.library.form;

import gemini.castor.ui.client.constants.I18nConstants;
import gemini.castor.ui.client.page.widget.promotion.PromotionWidget;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class LibraryFormView extends Composite implements
		LibraryFormPresenter.Display {

	@UiTemplate("LibraryFormView.ui.xml")
	interface MyUiBinder extends UiBinder<Panel, LibraryFormView> {
	}

	private static final MyUiBinder binder = GWT.create(MyUiBinder.class);
	private I18nConstants constants;

	public LibraryFormView() {
		initWidget(binder.createAndBindUi(this));
		constants = GWT.create(I18nConstants.class);
	}

	@UiField
	VerticalPanel vplPromotions;
	
	@Override
	public Widget asWidget() {
		return this;
	}

	@Override
	public void loadData() {
		vplPromotions.clear();
		PromotionWidget pwg1 = new PromotionWidget();
		pwg1.loadData(
				"images/logo/herbalife_98x98.jpg",
				constants.htmPromotionName1(),
				constants.htmPromotionDetail1()
						+ "<br/><a href=\"documents/2011_ActiveWorldTeam_usen.pdf\">"
						+ constants.htmDownloadDoc() + "</a>");
		vplPromotions.add(pwg1);

		PromotionWidget pwg2 = new PromotionWidget();
		pwg2.loadData(
				"images/logo/herbalife_98x98.jpg",
				constants.htmPromotionName2(),
				constants.htmPromotionDetail2()
						+ "<br/><a href=\"documents/2011_ActiveWorldTeam_usen.pdf\">"
						+ constants.htmDownloadDoc() + "</a>");
		vplPromotions.add(pwg2);

		PromotionWidget pwg3 = new PromotionWidget();
		pwg3.loadData(
				"images/logo/herbalife_98x98.jpg",
				constants.htmPromotionName3(),
				constants.htmPromotionDetail3()
						+ "<br/><a href=\"documents/2011_ActiveWorldTeam_usen.pdf\">"
						+ constants.htmDownloadDoc() + "</a>");
		vplPromotions.add(pwg3);
		
		PromotionWidget pwg4 = new PromotionWidget();
		pwg4.loadData(
				"images/logo/herbalife_98x98.jpg",
				constants.htmPromotionName4(),
				constants.htmPromotionDetail4()
						+ "<br/><a href=\"documents/2011_ActiveWorldTeam_usen.pdf\">"
						+ constants.htmDownloadDoc() + "</a>");
		vplPromotions.add(pwg4);
	}

}
